<template>
  <div class="layout" :class="{'layout-hide-text': spanLeft < 5}">

    <Row type="flex">

      <i-col :span="spanLeft" class="layout-menu-left">
        <Menu active-name="3" theme="dark" width="auto">
          <div class="layout-logo-left"></div>
          <!--用户管理-->
          <Menu-item name="1">
            <Icon type="person" :size="iconSize"></Icon>
            <router-link :to="{name:'User'}">
            <span class="layout-text">
                用户管理
            </span>
            </router-link>
          </Menu-item>

          <!--角色管理-->
          <Menu-item name="2">
            <Icon type="person-stalker" :size="iconSize"></Icon>
            <router-link :to="{name:'Role'}">
              <span class="layout-text">
              角色管理
              </span>
            </router-link>
          </Menu-item>

          <!--汽车管理-->
          <Menu-item name="3">
            <Icon type="model-s" :size="iconSize"></Icon>
            <router-link :to="{name:'Car'}">
            <span class="layout-text">
              汽车管理
            </span>
            </router-link>
          </Menu-item>

          <!--订单管理-->
          <Menu-item name="4">
            <Icon type="ios-cart" :size="iconSize"></Icon>
            <router-link :to="{name:'Message'}">
            <span class="layout-text">
              留言管理
            </span>
            </router-link>
          </Menu-item>

          <!--活动管理-->
          <Menu-item name="5">
            <Icon type="ios-navigate" :size="iconSize"></Icon>
            <router-link :to="{name:'Notice'}">
            <span class="layout-text">
              活动管理
            </span>
            </router-link>
          </Menu-item>
        </Menu>
      </i-col>
      <i-col :span="spanRight">
        <div class="layout-header">
          <i-button type="text" @click="toggleClick">
            <Icon type="navicon" size="32"></Icon>
          </i-button>
          <div class="my_header_right" style="float: right;margin-top: 15px;margin-right: 50px">
            <span style="font-size: 20px">当前用户：{{data.username}}</span>&nbsp;
            <span><router-link :to="{name:'Index'}" style="font-size: 15px;color: #545c64">退出登录</router-link></span>
          </div>
        </div>


        <div class="layout-breadcrumb">
          <Breadcrumb>
            <Breadcrumb-item>
              <router-link :to="{name:'Index'}">首页</router-link>
            </Breadcrumb-item>
            <Breadcrumb-item>
              <router-link :to="{name:'Main'}">后台管理</router-link>
            </Breadcrumb-item>
            <Breadcrumb-item></Breadcrumb-item>
          </Breadcrumb>
        </div>
        <div class="layout-content">
          <div class="layout-content-main">
            <router-view></router-view>
          </div>
        </div>
        <div class="layout-copy">
          2020-2021 &copy; TalkingData
        </div>
      </i-col>
    </Row>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        spanLeft: 5,
        spanRight: 19,
        data:{},//查询到的数据
      }
    },
    computed: {
      iconSize() {
        return this.spanLeft === 5 ? 14 : 24;
      }
    },
    methods: {
      toggleClick() {
        if (this.spanLeft === 5) {
          this.spanLeft = 2;
          this.spanRight = 22;
        } else {
          this.spanLeft = 5;
          this.spanRight = 19;
        }
      },
      /*查询所有用户*/
      findAll(id){//查询所有
        let _this = this
        console.log(id)
        this.$axios.get("http://localhost:8089/user/getUserById/"+id).then(function(res){
          _this.data = res.data
          console.log(_this.data)
        }).catch(function (err) {
          alert('查询失败')
        })
      },
      //初始化阶段 brforeCreate 内部事件 生命周期
    },
    mounted(){
      this.findAll(this.$route.params.id);
    },

  }
</script>

<style scoped>
  .layout {
    border: 1px solid #d7dde4;
    background: #f5f7f9;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
  }

  .layout-breadcrumb {
    padding: 10px 15px 0;
  }

  .layout-content {
    min-height: 200px;
    margin: 15px;
    height: 530px;
    overflow: hidden;
    background: #fff;
    border-radius: 4px;
  }

  .layout-content-main {
    padding: 10px;
  }

  .layout-copy {
    text-align: center;
    padding: 20px 0 20px;
    color: #9ea7b4;
  }

  .layout-menu-left {
    height: 710px;
    background: #464c5b;
  }

  .layout-header {
    height: 60px;
    background: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
  }

  .layout-logo-left {
    width: 90%;
    height: 30px;
    background: #5b6270;
    border-radius: 3px;
    margin: 15px auto;
  }

  .layout-ceiling-main a {
    color: #9ba7b5;
  }

  .layout-hide-text .layout-text {
    display: none;
  }
  .layout-text{
    color:white;
  }
  .layout-text:hover{
    color: #2b99ff;
  }
</style>
